import 'package:flutter/material.dart';
import 'package:wanandroid/common/common_index.dart';
import 'package:wanandroid/pages/page_index.dart';

class WebScaffold extends StatefulWidget {
  final String title;
  final String titleId;
  final String url;

  const WebScaffold({
    Key key,
    this.title,
    this.titleId,
    this.url,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _WebScaffoldState();
  }
}

class _WebScaffoldState extends State<WebScaffold> {
  final GlobalKey<WebviewScaffoldState> _webScaffoldKey =
      new GlobalKey<WebviewScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return WebviewScaffold(
      key: _webScaffoldKey,
      appBar: AppBar(
        title: InkWell(
          onDoubleTap: () {
            _webScaffoldKey.currentState.scrollToTop();
          },
          child: Text(
            widget.title ?? IntlUtil.getString(context, widget.titleId),
            maxLines: 1,
            // overflow: TextOverflow.ellipsis,
          ),
        ),
        centerTitle: true,
        actions: <Widget>[
          new IconButton(
            icon: Icon(Icons.more_vert),
            onPressed: () {},
          )
        ],
      ),
      url: widget.url,
    );
  }
}
